package com.woniuxy.day09springmvc3.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/*
@Controller注册到Spring容器中，并非昨日的bean标签 id =”/first“
仅仅只是在Spring中注册一个bean，名字叫做rbacManagerController,我们可以通过getBean获取到
 */
@Controller
//今日份请求url怎么配置呢？ 一级路由地址  localhost:8080/user/findOne
@RequestMapping("/user")
public class RbacManagerController{
    @RequestMapping("/findOne")
    public ModelAndView findOnefine(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg","我的findOne方法进入了");
        modelAndView.setViewName("success");
        return modelAndView;
    }
    @RequestMapping(path = "/findTwo",method = RequestMethod.GET)
    public ModelAndView findTwo(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg","我的findTwo方法进入了");
        modelAndView.setViewName("success");
        return modelAndView;
    }
    @RequestMapping({"/first","/second"})
    public ModelAndView first() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg","我的{\"/first\",\"/second\"}方法进入了");
        modelAndView.setViewName("success");
        return modelAndView;
    }
    //localhost:8080/user/aslidfjklasjdfiljaosildjfljthird
    //问号占位符 只能写一个字符，而且必须存在一个字符   third就无法访问了
    @RequestMapping({"/*third","/?third"})
    public ModelAndView third() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg","我的/*third方法进入了");
        modelAndView.setViewName("/index.jsp");
        return modelAndView;
    }
    //localhost:8080/user/fasdfasdfa/third1
    @RequestMapping("/*/third1")
    public ModelAndView third1() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg","我的/*/third1方法进入了");
        modelAndView.setViewName("/index.jsp");
        return modelAndView;
    }
    //localhost:8080/user/任意层级/任意字符/third2
    @RequestMapping("/**/third2")
    public ModelAndView third2() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg","我的/**/third2方法进入了");
        modelAndView.setViewName("/index.jsp");
        return modelAndView;
    }
}
